package com.day1011;

import com.sun.org.apache.bcel.internal.generic.ARRAYLENGTH;
import org.omg.CORBA.ARG_IN;

import java.util.Arrays;
import java.util.Scanner;

public class Suibi {

    public int[] add(int[] nums,int index,int num){
        int[] newnums = Arrays.copyOf(nums,nums.length + 1);
        newnums[index] = num;
//        for (int i = index; i < nums.length; i++) {
//            newnums[i+1] = nums[i];
//        }
        for (int i = nums.length-1; i >= index; i--) {
            newnums[i+1] = nums[i];
        }
        return newnums;
    }

    public int[] adds(int[] numsArray,int index,int nums,int...num){
        int[] newnums = Arrays.copyOf(numsArray,numsArray.length+nums);
        for (int i = 0; i < num.length; i++) {
            newnums[i+index] = num[i];
        }
        for (int i = index+nums; i < newnums.length; i++) {
            newnums[i] = numsArray[i-nums];
        }
        return newnums;
    }

    public int[] delete(int[] numsArray){
        numsArray = Arrays.copyOf(numsArray,numsArray.length-1);
        return numsArray;
    }

    public int[] del(int[] numsArray,int index){
        for (int i = index; i < numsArray.length-1; i++) {
            numsArray[i] = numsArray[i+1];
        }
        numsArray = Arrays.copyOf(numsArray,numsArray.length-1);
        return numsArray;
    }

    public int[] dels(int[] numsArray,int index,int nums){
        for (int i = index; i < numsArray.length-nums; i++) {
            numsArray[i] = numsArray[i+nums];
        }
        numsArray = Arrays.copyOf(numsArray,numsArray.length-nums);
        return numsArray;
    }

    public int[] revise(int[] numsArray,int index,int num){
        numsArray[index] = num;
        return  numsArray;
    }

    public int[] maopao(int[] nums){
        for (int i = 0; i < nums.length-1; i++) {
            for (int j = 0; j < nums.length-1-i; j++) {
                if (nums[j] < nums[j+1]){
                    int temp = nums[j];
                    nums[j] = nums[j+1];
                    nums[j+1] = temp;
                }
            }
        }
        return nums;
    }

    public static void main(String[] args) {
        Suibi suibi = new Suibi();
        //int[] nums = {11,2,32,41,25,16,77,48};
        //int[] newnums = suibi.add(nums,2,10);
        //int[] newnums = suibi.dels(nums,2,5);
//        int[] newnums = suibi.revise(nums,2,8);
//        for (int i = 0; i < newnums.length; i++) {
//            System.out.print(newnums[i] + " ");
//        }
//        int[] nums = {11,2,32,41,25,16,77,48};
//        suibi.maopao(nums);
//        for (int i = 0; i < nums.length; i++) {
//            System.out.print(nums[i] + " ");
//        }

        int[][] nums = {{1,2,3},{4,5,6},{7,8,9}};
        for (int i = 0; i < nums.length; i++) {
            for (int j = 0; j < nums[i].length; j++) {
                System.out.print(nums[i][j] + " ");
            }
            System.out.println();
        }

    }
}
